package member.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;
//import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
 
import member.vo.MemberVO;
 
public class MemberDAO  {
	
	 private SqlMapClientTemplate sqlMap;
	
	 public MemberDAO(SqlMapClientTemplate sqlMap){
		 this.sqlMap = sqlMap;
	 }
	 
	 
	 
	 
	 
	 public MemberVO selectMemberById(String id) {
		 return (MemberVO) sqlMap.queryForObject("selectMemberById", id);
	 }
	 
	 //주민번호로 조회
	 public MemberVO selectMemberByRegisterNumber(String N1, String N2) throws SQLException{
		  HashMap<String, String> map = new HashMap<String, String>();
		  map.put("registerNumber1", N1);
		  map.put("registerNumber2", N2);
		  
		  return (MemberVO)sqlMap.queryForObject("selectMemberByRegisterNumber",map);
	 }
	 
	 //회원데이터 insert메소드
	 public Object insertMember(MemberVO memberVO) throws SQLException{
		 return sqlMap.insert("insertMember", memberVO);
	 }
	 
	 public ArrayList<MemberVO> selectAllMember() {
		 return (ArrayList<MemberVO>) sqlMap.queryForList("selectAllMember");
	 }
	 
	 //회원 데이터 update
	 public int updateMember(MemberVO memberVO) {
		 return sqlMap.update("updateMember", memberVO);
	 }	
	 
	 public int deleteMemberById(String id) {
		 return sqlMap.delete("deleteMemberById", id);
	 }
	 
	 /*public ArrayList<MemberVO> selectMemberByMileageRange(int startMileage, int endMileage) {
		  HashMap map = new HashMap();
		  map.put("startMileage", startMileage);
		  map.put("endMileage",endMileage);
		  System.out.println("map : "+map);
		  return (ArrayList<MemberVO>) sqlMap.queryForList("selectMemberByMileageRange", map);
	 }*/
	 
	 public ArrayList<MemberVO> searchByMemberName(String name) {
		 return (ArrayList<MemberVO>) sqlMap.queryForList("searchByMemberName", name);
	 }
	 
}
